#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk/x11/gdkx.h>
#include <X11/Xlib.h>

static void on_activate (GtkApplication *app) {
  GtkWidget *window = gtk_application_window_new (app);
  gtk_widget_realize(window);
  GdkSurface* surface = gtk_native_get_surface(GTK_NATIVE (window));
  printf("%p\n", surface); //print (nil)
  Window   xw = gdk_x11_surface_get_xid(surface);
  Display *xd = gdk_x11_display_get_xdisplay(gtk_widget_get_display(window));
  XMoveWindow (xd, xw, 800, 600);
  gtk_window_present (GTK_WINDOW (window));
}

int main (int argc, char *argv[]) {
  GtkApplication *app = gtk_application_new ("com.example.GtkApplication",
                                         G_APPLICATION_FLAGS_NONE);                           g_signal_connect (app, "activate", G_CALLBACK (on_activate), NULL);
  return g_application_run (G_APPLICATION (app), argc, argv);
}
